﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.CApEportToRTRStatusIssueBuilderString
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.ExportToRTR.Resources;
using System;
using System.Collections.Generic;
using System.Text;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportToRTR{

internal class CApEportToRTRStatusIssueBuilderString : CApExportToRTRStatusIssueBuilder
{
  private StringBuilder m_statusBuilder;
  private int m_numberOfLineBreaks;
  private static (string, string)[] m_statusMetaData = new (string, string)[25]
  {
    (ExportToRTRStringTable.ISSUE01_OUTPUT_RTR_API_ACCESS, string.Empty),
    (ExportToRTRStringTable.ISSUE02_COULD_NOT_ACCESS_HOST, string.Empty),
    (ExportToRTRStringTable.ISSUE03_OUTPUT_RTR_NO_HOST_NAME, string.Empty),
    (ExportToRTRStringTable.ISSUE04_OUTPUT_NO_PAKAGE_NAME, string.Empty),
    (ExportToRTRStringTable.ISSUE05_OUTPUT_RTR_EXISTING_PAKAGE_NAME, string.Empty),
    (ExportToRTRStringTable.ISSUE12_INVALID_CHARACTERS_PROJECT_NAME, string.Empty),
    (ExportToRTRStringTable.ISSUE06_NO_SLECTED_OBJECTS, string.Empty),
    (string.Format(ExportToRTRStringTable.WARNING_01_LOCATIONS_EXCLUDED, (object) ExportToRTRStringTable.WARNING_02_LOCATION_EXCLUDED_REACH), ExportToRTRStringTable.WARNING_04_LOCATION_OPERATION_ROBOT),
    (string.Format(ExportToRTRStringTable.WARNING_01_LOCATIONS_EXCLUDED, (object) ExportToRTRStringTable.WARNING_03_LOCATION_EXCLUDED_CONFIG), ExportToRTRStringTable.WARNING_04_LOCATION_OPERATION_ROBOT),
    (string.Format(ExportToRTRStringTable.WARNING_01_LOCATIONS_EXCLUDED, (object) ExportToRTRStringTable.WARNING_05_LOCATION_EXCLUDED_COLLISION), ExportToRTRStringTable.WARNING_04_LOCATION_OPERATION_ROBOT),
    (string.Format(ExportToRTRStringTable.WARNING_06_OBJECT_WARNING, (object) ExportToRTRStringTable.WARNING_06_01_OBJECT_GUN, (object) ExportToRTRStringTable.WARNING_06_11_GUN_LOOP_WARNING), "{0}"),
    (string.Format(ExportToRTRStringTable.WARNING_06_OBJECT_WARNING, (object) ExportToRTRStringTable.WARNING_06_01_OBJECT_GUN, (object) ExportToRTRStringTable.WARNING_06_12_GUN_VALID_KINEMATICS_WARNING), "{0}"),
    (ExportToRTRStringTable.ISSUE13_TOOL_GUN_LIMITS, "{0}"),
    (ExportToRTRStringTable.ISSUE14_TOOL_GUN_COMPENSATION_JOINT, "{0}"),
    (ExportToRTRStringTable.ISSUE15_TOOL_GUN_ROBOT_TOOL_UNSUPPORTED_EXTERNAL_JOINT, "{0}"),
    (string.Format(ExportToRTRStringTable.WARNING_06_OBJECT_WARNING, (object) ExportToRTRStringTable.WARNING_06_03_OBJECT_TOOL, (object) ExportToRTRStringTable.WARNING_06_13_TOOL_EXTERNAL_AXIS_MONOLITHINC_WARNING), "{0}"),
    (ExportToRTRStringTable.ISSUE16_GENERAL_NO_VALID_OPERATION, string.Empty),
    (ExportToRTRStringTable.ISSUE17_OPERATION_SIMULATED_ROBOT_MISSING, "{0}"),
    (ExportToRTRStringTable.ISSUE18_OPERATION_SIMULATED_ROBOT_BLANKED, "{0}"),
    (ExportToRTRStringTable.ISSUE19_OPERATION_SIMULATED_ROBOT_7_AXIS, "{0}"),
    (ExportToRTRStringTable.ISSUE20_GENERAL_COLLISION_SETS_MISSING, string.Empty),
    (ExportToRTRStringTable.ISSUE21_NO_COMPUTED_COLLISION_SETS_FOR_ROBOT, "{0}"),
    (ExportToRTRStringTable.ISSUE22_BLANKED_ATTACHED_DEVICES, ExportToRTRStringTable.ISSUE22_BLANKED_ATTACHED_DEVICES_OBJECT),
    (ExportToRTRStringTable.ISSUE23_BLANKED_SUB_DEVICES, ExportToRTRStringTable.ISSUE22_BLANKED_ATTACHED_DEVICES_OBJECT),
    (string.Format(ExportToRTRStringTable.ISSUE24_PROJECT_SLOTS_ARE_FULL, (object) "10"), string.Empty)
  };

  internal CApEportToRTRStatusIssueBuilderString(
    StringBuilder statusBuilder,
    int numberOfLineBreaks = 2)
  {
    this.m_statusBuilder = statusBuilder;
    this.m_numberOfLineBreaks = numberOfLineBreaks;
  }

  internal override void AppendObject(
    CApExportToRTRStatusManager.IssueType type,
    CApExportToRTRStatusObjectIssueData data)
  {
    string format = CApEportToRTRStatusIssueBuilderString.m_statusMetaData[(int) type].Item2;
    if (format == null)
      return;
    List<string> objectNames = new List<string>();
    data.AllObjects.ForEach((Action<ITxObject>) (obj => objectNames.Add(obj.Name)));
    this.m_statusBuilder.Append(string.Format(format, (object[]) objectNames.ToArray()));
  }

  internal override void AppendObjectList(
    CApExportToRTRStatusManager.IssueType type,
    HashSet<CApExportToRTRStatusObjectIssueData> dataList)
  {
    if (string.IsNullOrEmpty(CApEportToRTRStatusIssueBuilderString.m_statusMetaData[(int) type].Item2))
      return;
    int num = 1;
    foreach (CApExportToRTRStatusObjectIssueData data in dataList)
    {
      this.m_statusBuilder.Append($"\n   {num++}) ");
      this.AppendObject(type, data);
    }
  }

  internal override void AppendTitle(
    CApExportToRTRStatusManager.IssueType type,
    CApExportToRTRStatusManager.Severity severity,
    string additionalData = null)
  {
    string str = CApEportToRTRStatusIssueBuilderString.m_statusMetaData[(int) type].Item1;
    if (severity == CApExportToRTRStatusManager.Severity.Error)
    {
      this.m_statusBuilder.Append("❌ " + str);
    }
    else
    {
      if (severity != CApExportToRTRStatusManager.Severity.Warning)
        return;
      this.m_statusBuilder.Append("⚠ " + str);
    }
  }

  internal override void PreAppendNextObjectList()
  {
    StringBuilder stringBuilder = new StringBuilder();
    for (int index = 0; index < this.m_numberOfLineBreaks; ++index)
      stringBuilder.Append("\n");
    this.m_statusBuilder.Append(stringBuilder.ToString());
  }

  internal override CApExportToRTRStatusIssueBuilder ScopeBuilder
  {
    get => (CApExportToRTRStatusIssueBuilder) null;
  }
}
}